﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Casemeet.Groups;
using VK.Comm;

namespace VK.Casemeet.Web.Front
{
    public partial class Group : System.Web.UI.Page
    {
        public int gcid = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
             gcid = Util.GetQueryInt("gcid");
            if (!IsPostBack)
            {
                //分类列表
                repCategoris.DataSource = GroupsBLL.GetCategories(0, "");
                repCategoris.DataBind();

                aspNetPager.RecordCount = GroupsBLL.GroupCount(gcid, 0, (this.Master as Site).GetCurrentAreaID());
                GroupList();
            }
        }

        //团购列表
        private void GroupList()
        {
            repGroups.DataSource = GroupsBLL.GetGroups(aspNetPager.StartRecordIndex, aspNetPager.EndRecordIndex, gcid, 0, (this.Master as Site).GetCurrentAreaID());
            repGroups.DataBind();
        }


        protected void aspNetPager_PageChanged(object sender, EventArgs e)
        {
            GroupList();
        }

      

        /// <summary>
        /// 算出折扣
        /// </summary>
        /// <param name="origprice"></param>
        /// <param name="disprice"></param>
        /// <returns></returns>
        public string DisCount(string origprice, string disprice)
        {
            Single orignum = 0; Single disnum = 0;
            Single.TryParse(origprice, out orignum);
            Single.TryParse(disprice, out disnum);
            if (disnum == 0)
                return "";

            return Math.Round((disnum / orignum*10), 1).ToString();
        }
    }
}